package com.tencent.yolov5ncnn

import android.app.Activity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.FragmentActivity

class index : FragmentActivity() {
    private var change: Button? = null
    private var phoneCameraView: View? = null
    private var monitorView: View? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_index)
        change=findViewById<View>(R.id.changes) as Button
          phoneCameraView = findViewById<View>(R.id.phoneCameraView)
          monitorView = findViewById<View>(R.id.monitorView)
change!!.setOnClickListener {
    change()
}
    }

    private fun change(){

        if (monitorView?.visibility== View.VISIBLE&&phoneCameraView?.visibility == View.GONE) {
            monitorView?.visibility = View.GONE
            phoneCameraView?.visibility = View.VISIBLE
        }
        else{
            phoneCameraView?.visibility = View.GONE
            monitorView?.visibility = View.VISIBLE
        }
    }
    override fun  onResume(){
        super.onResume()
// 在接收Activity中
val intent2 = getIntent()
val wifiName = intent2.getStringExtra("wifiName")
        if (wifiName != null) {
            if (wifiName.startsWith("IPCAM")) {
                phoneCameraView?.visibility = View.GONE
                monitorView?.visibility = View.VISIBLE
            } else {
                monitorView?.visibility = View.GONE
                phoneCameraView?.visibility = View.VISIBLE
            }
        }
//        Log.d("$wifiName","$wifiName")
    }

}
